package sagroup.util;

import java.lang.reflect.Array;

public class Arrayss {
	public static <T> T[] mergeArrays(T[][] twod, Class c) {
		int len = 0;
		T[] oned = null;
		for (int i = 0; i < twod.length; i++) {
			oned = twod[i];
			if (oned != null)
				len += oned.length;
		}
		T[] ret = (T[]) Array.newInstance(c, len);
		int j = 0;
		for (int i = 0; i < twod.length; i++) {
			oned = twod[i];
			if (oned != null) {
				for (int k = 0; k < oned.length; k++, j++) {
					ret[j] = oned[k];
				}
			}
		}
		return ret;
	}
}
